package com.hikari.cloud.base.rabbitmq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;


@Component
public class DirectConsumer {

    public static final Logger logger = LoggerFactory.getLogger(DirectConsumer.class);

    /****
     * 监听直连的队列，一旦此队列出现数据，则自动消费此队列的数据
     * @param message
     * @throws Exception
     */
    @RabbitListener(queues = {QueueConfig.QUEUE_DIRECT_NAME}, containerFactory = "rabbitListenerContainerFactory")
    public void handleMessage(String message) throws Exception {
        // 处理消息
        logger.info("直连模式队列：{}, 消费者： 接收到消息如下：{} ", QueueConfig.QUEUE_DIRECT_NAME, message);
    }

}